﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using LP580.CG;

public partial class Company : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            int id = Utils.RQ_int("id");

            clsUserCompanyInfo com = new clsUserCompanyInfo(id);
            com.Hits();

            int uid = Utils.RQ_int("u");
            if (uid == 0) uid = id;

            //添加浏览记录
            List<string> lsUid;
            int countUid = 6;//设置浏览记录数的最大值
            if (Request.Cookies["fav"] != null && Request.Cookies["fav"]["c"] != null)
            {
                lsUid = new List<string>(Request.Cookies["fav"]["c"].Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries));
                if (lsUid.Contains(uid.ToString()))
                    lsUid.Remove(uid.ToString());//当前记录已存在,移除
                if (lsUid.Count > countUid)
                    lsUid.RemoveAt(countUid);//记录数达到最大值，移除最早记录
            }
            else
            {
                lsUid = new List<string>();
            }
            lsUid.Insert(0, uid.ToString());
            HttpCookie coo = new HttpCookie("fav");
            coo["c"] = string.Join(",", lsUid.ToArray());
            coo.Expires = DateTime.MaxValue;
            HttpContext.Current.Response.Cookies.Add(coo);

            //绑定用户控件
            UserInfo.uid = uid;
            UserClass.uid = uid;
        }
    }
}